package com.haoxi.gateway.cmppmsg;

import com.haoxi.gateway.util.TypeConvert;

public class CMPPSubmitRepMessage extends CMPPMessage {

    public CMPPSubmitRepMessage(byte buf[]) throws IllegalArgumentException {
        super.buf = new byte[13];
        if (buf.length != 13) {
            throw new IllegalArgumentException(
                    "The message that is sent by SMC is wrong");
        } else {
            System.arraycopy(buf, 0, super.buf, 0, 13);
            sequence_Id = TypeConvert.byte2int(super.buf, 0);
        }
    }

    public byte[] getMsgId() {
        byte tmpMsgId[] = new byte[8];
        System.arraycopy(buf, 4, tmpMsgId, 0, 8);
        return tmpMsgId;
    }

    public int getResult() {
        return buf[12];
    }

    public String toString() {
        StringBuffer tmpBuf = new StringBuffer("CMPP_Submit_RESP: ");
        tmpBuf.append("Sequence_Id=").append(getSequenceId());
        tmpBuf.append(",MsgId=").append(CMPPCommon.getMsgIdStr(getMsgId()));
        tmpBuf.append(",Result=").append(getResult());
        return tmpBuf.toString();
    }

    public int getCommandId() {
        return CMPPCommon.CMPP_SUBMIT_RESP;
    }
}
